/*
 * constants.h
 *
 *  Created on: 03.05.2011
 *      Author: Jasper
 */

#ifndef CONSTANTS_H_
#define CONSTANTS_H_

// definition, welches Band gesteuert werden soll
// 1 = Band1, 2 = Band2
#define BANDNo 1

// Ports
#define PORT_A DIO_PORTA_OFFSET << 8
#define PORT_B DIO_PORTB_OFFSET << 8
#define PORT_C DIO_PORTC_OFFSET << 8

// Port A
#define MOT_RECHTS (PORT_A) | 0x01
#define MOT_LINKS (PORT_A) | 0x02
#define MOT_SLOW (PORT_A) | 0x04
#define MOT_STOP (PORT_A) | 0x08
#define WEICHE (PORT_A) | 0x10
#define AMPEL_GRUN (PORT_A) | 0x20
#define AMPEL_GELB (PORT_A) | 0x40
#define AMPEL_ROT (PORT_A) | 0x80

// Port B
#define WKST_EINL (PORT_B) | 0x01
#define WKST_HO_MESS (PORT_B) | 0x02
#define WKST_HO_OK (PORT_B) | 0x04
#define WKST_WEICHE (PORT_B) | 0x08
#define WKST_MET (PORT_B) | 0x10
#define WEICHE_OPEN (PORT_B) | 0x20
#define RUTSCH_VOLL (PORT_B) | 0x40
#define WKST_AUSL (PORT_B) | 0x80

// Port C
#define LED_STARTTASTE (PORT_C) | 0x01
#define LED_RESETTASTE (PORT_C) | 0x02
#define LED_Q1 (PORT_C) | 0x04
#define LED_Q2 (PORT_C) | 0x08
#define BUT_START (PORT_C) | 0x10
#define BUT_STOP ((PORT_C) | 0x20)
#define BUT_RESET (PORT_C) | 0x40
#define BUT_NOTAUS (PORT_C) | 0x80

// HW-Ports
#define DIO_BASEADDR 0x300
#define DIO_PORTA_OFFSET 0x00
#define DIO_PORTB_OFFSET 0x01
#define DIO_PORTC_OFFSET 0x02
#define DIO_CONTROL_OFFSET 0x03
#define DIO_INTERRUPT_ENABLE 0x0B
#define DIO_CLR_IRQ_READ 0x18
#define DIO_CLR_IRQ_WRITE 0x0F

#define AIO_BASEADDR 0x320
#define AIO_BOARD_STATUS 0x00
#define AIO_ADC_LOW 0x02
#define AIO_ADC_HIGH 0x03
#define AIO_AD_CONTROL 0x02

// IRQ
#define IRQ 11

// Connection states
#define SYNHELLO 	1
#define SYNHELLOACK	2
#define SYNTIMEOUT 	3
#define SYNCHECK 	4
#define SYNCHECKACK	5
#define SYNWAIT		6

// BandKontroller
#define TIMER1TIMEOUT 		11
#define TIMER2TIMEOUT 			12
#define TIMER3TIMEOUT 			13
#define NOTCONNECTED 			123
#define CONNECTED 				1234
#define ON						1
#define OFF						0
#define STOPBUTTON				9
#define STARTBUTTON				8
#define WORKPIECES				60
#define WORKPIECERAMPFULL 		60
#define WORKPIECETIMEOUT		61
#define WORKPIECESORTOUT		62
#define WORKPIECETOOFAST		63
#define WORKPIECETOOFLAT		64
#define DELIVERYREQUEST			101
#define DELIVERYACKNOWLEGE		201
#define BLINKING				100
#define WORKPIECENEW 			1
#define WORKPIECEMESSURE 		2
#define RAMPFULL				4
#define NOTAUS					5
#define WORKPIECEDONE			6
#define BUTTONRESET				7
#define BUTTONSTART				8
#define BUTTONSTOP				9
#define WORKPIECEANNOUNCEMENT 	30




// ERRORCODE von WERKSTUECK
// Werksteuck1 = 6X, Werksteuck2 = 7X, Werksteuck3 = 8X
// X1 = TIMEOUT LS1 usw, X0 = Rutsche voll, X2 = wird aussortiert, X3 = to fast


#endif /* CONSTANTS_H_ */
